package mapReduce.homework.q4_getTotalMoney;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class GetTotalMoneyByPartnerPartitioner extends Partitioner<Text,DoubleWritable> {

    @Override
    public int getPartition(Text text, DoubleWritable doubleWritable, int numPartitions) {
        String key = text.toString();
        String partner = key.split("\t")[1];

        int res = 0;

        if(partner.contains("艺龙网")){
            res = 0;
        }else if(partner.contains("携程网")){
            res = 1;
        }else if(partner.contains("去哪网")){
            res = 2;
        }else if(partner.contains("58旅游")){
            res = 3;
        }
        return res;
    }
}
